clear
rng default
load IdSetM
load IdSetW
ntypes_m=3;
ntypes_w=3;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%% Projections in one dimension %%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Phi=cell(ntypes_m, ntypes_w);
for i=2:ntypes_m+1
    for j=2:ntypes_w+1
        M=unique(IdSetM{i-1}(:,j), 'rows', 'stable'); 
        W=unique(IdSetW{j-1}(:,i), 'rows', 'stable');
        sm=size(M,1);
        temp=cell(sm,1);
        for k=1:sm
            temp{k}=M(k)+W(:); 
        end
        temp=vertcat(temp{:});
        Phi{i-1,j-1}=[min(temp); max(temp)];
    end
end

save('Phi_intervals.mat', 'Phi')

load U_CS
load V_CS

Phi_CS=U_CS+V_CS;
save('Phi_CS.mat', 'Phi_CS')

